package hawk.example.jdk.concurrency;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Scanner;

public class ProcessDemo {
    public static void main(String[] args) throws InterruptedException, IOException {

        Process p = new ProcessBuilder("cmd.exe","/c","dir")
                .directory(Path.of("c:/mydata/temp/").toFile())
                .start();
        try (var in = new Scanner(p.getInputStream())) {
            while (in.hasNextLine())
                System.out.println(in.nextLine());
        }
        int result = p.waitFor();
        System.out.println("Exit value: " + result);
    }
}